home *** CD-ROM | disk | FTP | other *** search
/ System Booster / System Booster.iso / Screenblankers / GBlanker / GSource / Blankers / Maze / blank.c next >
C/C++ Source or Header  |  1996-09-26  |  14KB  |  674 lines

  1. /*
  2.  *  Copyright (c) 1994 Michael D. Bayne.
  3.  *  All rights reserved.
  4.  *
  5.  *  Please see the documentation accompanying the distribution for distribution
  6.  *  and disclaimer information.
  7.  */
  8.  
  9. #include <exec/memory.h>
  10. #include <hardware/custom.h>
  11. #include "/includes.h"
  12.  
  13. #define CELLSIZE 0
  14. #define SOLVEDEL 2
  15. #define COPPER   4
  16. #define MODE     6
  17.  
  18. extern __far struct Custom custom;
  19.  
  20. #define NORTH 0
  21. #define EAST  1
  22. #define SOUTH 2
  23. #define WEST  3
  24.  
  25. #define HasBeenVisited( Bob, x, y )\
  26. ( (Bob)->mz_Cells[(x)*(Bob)->mz_Height+(y)] )
  27. #define Visit( Bob, x, y )\
  28. ( (Bob)->mz_Cells[(x)*(Bob)->mz_Height+(y)] = 1 )
  29.  
  30. LONG DirArray[] = {
  31.     0x00010203, 0x00010302, 0x00020103, 0x00020301, 0x00030102, 0x00030201,
  32.     0x01000203, 0x01000302, 0x01020003, 0x01020300, 0x01030002, 0x01030200,
  33.     0x02000103, 0x02000301, 0x02010003, 0x02010300, 0x02030001, 0x02030100,
  34.     0x03000102, 0x03000201, 0x03010002, 0x03010200, 0x03020001, 0x03020100
  35.     };
  36.  
  37. typedef struct _Stack
  38. {
  39.     LONG st_x;
  40.     LONG st_y;
  41.     BYTE st_DirOne;
  42.     BYTE st_DirTwo;
  43.     BYTE st_DirThree;
  44.     BYTE st_DirFour;
  45.     struct _Stack *st_Prev;
  46. } Stack;
  47.  
  48. typedef struct _Maze
  49. {
  50.     struct RastPort *mz_Rast;
  51.     LONG mz_Width;
  52.     LONG mz_Height;
  53.     LONG mz_WidStep;
  54.     LONG mz_HeiStep;
  55.     BYTE *mz_Cells;
  56.     BYTE *mz_LeftWalls;
  57.     BYTE *mz_TopWalls;
  58.     Stack *mz_Stack;
  59. } Maze;
  60.  
  61. LONG StackLength, SolutionLength, NumCols, Copper;
  62. LONG Iter, SolPeriod, SolDelay;
  63. Triplet *ColorTable = 0L;
  64.  
  65. #include "Maze_rev.h"
  66. STATIC const UBYTE VersTag[] = VERSTAG;
  67.  
  68. VOID Defaults( PrefObject *Prefs )
  69. {
  70.     Prefs[CELLSIZE].po_Level = 7;
  71.         Prefs[SOLVEDEL].po_Level = 3;
  72.     Prefs[COPPER].po_Active = 1;
  73.     Prefs[MODE].po_ModeID = getTopScreenMode();
  74.     Prefs[MODE].po_Depth = 2;
  75. }
  76.  
  77. Stack *AllocStack( LONG x, LONG y, BYTE *Directions )
  78. {
  79.     Stack *New = AllocVec( sizeof( Stack ), MEMF_ANY );
  80.     
  81.     if( New )
  82.     {
  83.         New->st_x = x;
  84.         New->st_y = y;
  85.         CopyMem( Directions, &( New->st_DirOne ), 4 * sizeof( BYTE ));
  86.         New->st_Prev = 0L;
  87.     }
  88.     
  89.     return New;
  90. }
  91.  
  92. #define Push( b, c )\
  93. StackLength++; (c)->st_Prev = (b)->mz_Stack; (b)->mz_Stack = (c)
  94.  
  95. Stack *Pop( Maze *Bob )
  96. {
  97.     Stack *Popped = Bob->mz_Stack;
  98.     
  99.     if( Popped )
  100.     {
  101.         StackLength--;
  102.         Bob->mz_Stack = Popped->st_Prev;
  103.     }
  104.     
  105.     return Popped;
  106. }
  107.  
  108. VOID FreeMaze( Maze *FreeMe )
  109. {
  110.     if( FreeMe )
  111.     {
  112.         if( FreeMe->mz_Cells )
  113.             FreeVec( FreeMe->mz_Cells );
  114.         if( FreeMe->mz_LeftWalls )
  115.             FreeVec( FreeMe->mz_LeftWalls );
  116.         if( FreeMe->mz_TopWalls )
  117.             FreeVec( FreeMe->mz_TopWalls );
  118.         FreeVec( FreeMe );
  119.     }
  120. }
  121.  
  122. Maze *AllocMaze( struct Screen *Screen, LONG Width, LONG Height, LONG Flags )
  123. {
  124.     Maze *New;
  125.     
  126.     if( New = AllocVec( sizeof( Maze ), Flags ))
  127.     {
  128.         New->mz_Rast = &Screen->RastPort;
  129.         New->mz_Width = Width;
  130.         New->mz_Height = Height;
  131.         New->mz_WidStep = ( Screen->Width - 1 ) / Width;
  132.         New->mz_HeiStep = ( Screen->Height - 1 ) / Height;
  133.         New->mz_Cells = AllocVec( sizeof( BYTE ) * Width * Height, Flags );
  134.         New->mz_LeftWalls = AllocVec( sizeof( BYTE ) * ( Width + 1 ) * Height,
  135.                                      Flags );
  136.         New->mz_TopWalls = AllocVec( sizeof( BYTE ) * Width * ( Height + 1 ),
  137.                                     Flags );
  138.         
  139.         if( New->mz_Cells && New->mz_LeftWalls && New->mz_TopWalls )
  140.             return New;
  141.         
  142.         FreeMaze( New );
  143.     }
  144.     
  145.     return 0L;
  146. }
  147.  
  148. #define ActivateLeftWall( x, y )\
  149. ( Bob->mz_LeftWalls[(x)*Bob->mz_Height+(y)] = 1 )
  150. #define ActivateTopWall( x, y )\
  151. ( Bob->mz_TopWalls[(x)*Bob->mz_Height+(y)] = 1 )
  152.  
  153. #define LeftWallActive( x, y ) ( Bob->mz_LeftWalls[(x)*Bob->mz_Height+(y)] )
  154. #define TopWallActive( x, y ) ( Bob->mz_TopWalls[(x)*Bob->mz_Height+(y)] )
  155.  
  156. VOID AddHorizWall( Maze *Bob, LONG x, LONG y )
  157. {
  158.     Move( Bob->mz_Rast, x * Bob->mz_WidStep, y * Bob->mz_HeiStep );
  159.     Draw( Bob->mz_Rast, ( x + 1 ) * Bob->mz_WidStep, y * Bob->mz_HeiStep );
  160. }
  161.  
  162. VOID AddVertWall( Maze *Bob, LONG x, LONG y )
  163. {
  164.     Move( Bob->mz_Rast, x * Bob->mz_WidStep, y * Bob->mz_HeiStep );
  165.     Draw( Bob->mz_Rast, x * Bob->mz_WidStep, ( y + 1 ) * Bob->mz_HeiStep );
  166. }
  167.  
  168. VOID DrawSolution( Maze *Bob, LONG x, LONG y, LONG Pen, LONG Trailer )
  169. {
  170.     SetAPen( Bob->mz_Rast, Pen );
  171.     switch( Trailer )
  172.     {
  173.     case NORTH:
  174.         RectFill( Bob->mz_Rast, x * Bob->mz_WidStep + 1,
  175.                  y * Bob->mz_HeiStep + 1, ( x + 1 ) * Bob->mz_WidStep - 1,
  176.                  ( y + 1 ) * Bob->mz_HeiStep );
  177.         break;
  178.     case SOUTH:
  179.         RectFill( Bob->mz_Rast, x * Bob->mz_WidStep + 1, y * Bob->mz_HeiStep,
  180.                  ( x + 1 ) * Bob->mz_WidStep - 1,
  181.                  ( y + 1 ) * Bob->mz_HeiStep - 1 );
  182.         break;
  183.     case EAST:
  184.         RectFill( Bob->mz_Rast, x * Bob->mz_WidStep + 1,
  185.                  y * Bob->mz_HeiStep + 1, ( x + 1 ) * Bob->mz_WidStep,
  186.                  ( y + 1 ) * Bob->mz_HeiStep - 1 );
  187.         break;
  188.     case WEST:
  189.         RectFill( Bob->mz_Rast, x * Bob->mz_WidStep, y * Bob->mz_HeiStep + 1,
  190.                  ( x + 1 ) * Bob->mz_WidStep - 1,
  191.                  ( y + 1 ) * Bob->mz_HeiStep - 1 );
  192.         break;
  193.     }
  194.  
  195.     if(!( ++Iter % SolPeriod ))
  196.         Delay( SolDelay );
  197. }
  198.  
  199. BYTE *RemoveDir( BYTE *Dir, BYTE RemMe )
  200. {
  201.     static BYTE Dirs[4];
  202.     int i;
  203.     
  204.     for( i = 0; i < 4; i++ )
  205.     {
  206.         if( Dir[i] == RemMe )
  207.             Dirs[i] = 4;
  208.         else
  209.             Dirs[i] = Dir[i];
  210.     }
  211.     
  212.     return Dirs;
  213. }
  214.  
  215. #define DefRemDir( x ) RemoveDir(( BYTE * )&( DirArray[RangeRand( 24 )] ), x )
  216.  
  217. Stack *GoDirection( Maze *Bob, Stack *Cell, BYTE DirNum )
  218. {
  219.     LONG x = Cell->st_x, y = Cell->st_y;
  220.     BYTE Direction;
  221.     
  222.     switch( DirNum )
  223.     {
  224.     case 0:
  225.         Direction = Cell->st_DirOne;
  226.         Cell->st_DirOne = 4;
  227.         break;
  228.     case 1:
  229.         Direction = Cell->st_DirTwo;
  230.         Cell->st_DirTwo = 4;
  231.         break;
  232.     case 2:
  233.         Direction = Cell->st_DirThree;
  234.         Cell->st_DirThree = 4;
  235.         break;
  236.     case 3:
  237.         Direction = Cell->st_DirFour;
  238.         Cell->st_DirFour = 4;
  239.         break;
  240.     }
  241.     
  242.     switch( Direction )
  243.     {
  244.     case EAST:
  245.         if( x < Bob->mz_Width - 1 )
  246.         {
  247.             if( !HasBeenVisited( Bob, x + 1, y ))
  248.             {
  249.                 Push( Bob, Cell );
  250.                 return AllocStack( x + 1, y, DefRemDir( WEST ));
  251.             }
  252.             else
  253.             {
  254.                 AddVertWall( Bob, x + 1, y );
  255.                 ActivateLeftWall( x + 1, y );
  256.             }
  257.         }
  258.         break;
  259.     case NORTH:
  260.         if( y < Bob->mz_Height - 1 )
  261.         {
  262.             if( !HasBeenVisited( Bob, x, y + 1 ))
  263.             {
  264.                 Push( Bob, Cell );
  265.                 return AllocStack( x, y + 1, DefRemDir( SOUTH ));
  266.             }
  267.             else
  268.             {
  269.                 AddHorizWall( Bob, x, y + 1 );
  270.                 ActivateTopWall( x, y + 1 );
  271.             }
  272.         }
  273.         break;
  274.     case WEST:
  275.         if( x > 0 )
  276.         {
  277.             if( !HasBeenVisited( Bob, x - 1, y ))
  278.             {
  279.                 Push( Bob, Cell );
  280.                 return AllocStack( x - 1, y, DefRemDir( EAST ));
  281.             }
  282.             else
  283.             {
  284.                 AddVertWall( Bob, x, y );
  285.                 ActivateLeftWall( x, y );
  286.             }
  287.         }
  288.         break;
  289.     case SOUTH:
  290.         if( y > 0 )
  291.         {
  292.             if( !HasBeenVisited( Bob, x, y - 1 ))
  293.             {
  294.                 Push( Bob, Cell );
  295.                 return AllocStack( x, y - 1, DefRemDir( NORTH ));
  296.             }
  297.             else
  298.             {
  299.                 AddHorizWall( Bob, x, y );
  300.                 ActivateTopWall( x, y );
  301.             }
  302.         }
  303.         break;
  304.     default:
  305.         break;
  306.     }
  307.     
  308.     return 0L;
  309. }
  310.  
  311. LONG ConstructMaze( Maze *Bob, LONG x, LONG y, LONG sx, LONG sy )
  312. {
  313.     Stack *Cell, *NewCell;
  314.     LONG RetVal;
  315.     
  316.     Cell = AllocStack( x, y, ( BYTE * )&( DirArray[RangeRand( 24 )] ));
  317.     
  318.     do
  319.     {
  320.         RetVal = ContinueBlanking();
  321.         
  322.         if( Cell->st_x == sx && Cell->st_y == sy && !SolutionLength )
  323.             SolutionLength = StackLength;
  324.  
  325.         Visit( Bob, Cell->st_x, Cell->st_y );
  326.         
  327.         if( NewCell = GoDirection( Bob, Cell, 0 ))
  328.         {
  329.             Cell = NewCell;
  330.             continue;
  331.         }
  332.         
  333.         if( NewCell = GoDirection( Bob, Cell, 1 ))
  334.         {
  335.             Cell = NewCell;
  336.             continue;
  337.         }
  338.         
  339.         if( NewCell = GoDirection( Bob, Cell, 2 ))
  340.         {
  341.             Cell = NewCell;
  342.             continue;
  343.         }
  344.         
  345.         if( NewCell = GoDirection( Bob, Cell, 3 ))
  346.         {
  347.             Cell = NewCell;
  348.             continue;
  349.         }
  350.         
  351.         FreeVec( Cell );
  352.         Cell = Pop( Bob );
  353.     }
  354.     while( Cell &&( RetVal == OK ));
  355.     
  356.     if( Cell )
  357.     {
  358.         do
  359.             FreeVec( Cell );
  360.         while( Cell = Pop( Bob ));
  361.     }
  362.     
  363.     return RetVal;
  364. }
  365.  
  366. Stack *SolveDirection( Maze *Bob, Stack *Cell, BYTE DirNum )
  367. {
  368.     LONG x = Cell->st_x, y = Cell->st_y;
  369.     BYTE Direction;
  370.     
  371.     switch( DirNum )
  372.     {
  373.     case 0:
  374.         Direction = Cell->st_DirOne;
  375.         Cell->st_DirOne = 4;
  376.         break;
  377.     case 1:
  378.         Direction = Cell->st_DirTwo;
  379.         Cell->st_DirTwo = 4;
  380.         break;
  381.     case 2:
  382.         Direction = Cell->st_DirThree;
  383.         Cell->st_DirThree = 4;
  384.         break;
  385.     case 3:
  386.         Direction = Cell->st_DirFour;
  387.         Cell->st_DirFour = 4;
  388.         break;
  389.     }
  390.     
  391.     switch( Direction )
  392.     {
  393.     case EAST:
  394.         if( x < Bob->mz_Width - 1 )
  395.         {
  396.             if( !LeftWallActive( x + 1, y ))
  397.             {
  398.                 Push( Bob, Cell );
  399.                 DrawSolution( Bob, x + 1, y, Copper == 2 || Copper == 3 ?
  400.                              (( StackLength * NumCols / SolutionLength ) %
  401.                               NumCols ) + 1 : 3, WEST );
  402.                 return AllocStack( x + 1, y, DefRemDir( WEST ));
  403.             }
  404.         }
  405.         break;
  406.     case NORTH:
  407.         if( y < Bob->mz_Height - 1 )
  408.         {
  409.             if( !TopWallActive( x, y + 1 ))
  410.             {
  411.                 Push( Bob, Cell );
  412.                 DrawSolution( Bob, x, y + 1, Copper == 2 || Copper == 3 ?
  413.                              (( StackLength * NumCols / SolutionLength ) %
  414.                               NumCols ) + 1 : 3, SOUTH );
  415.                 return AllocStack( x, y + 1, DefRemDir( SOUTH ));
  416.             }
  417.         }
  418.         break;
  419.     case WEST:
  420.         if( x > 0 )
  421.         {
  422.             if( !LeftWallActive( x, y ))
  423.             {
  424.                 Push( Bob, Cell );
  425.                 DrawSolution( Bob, x - 1, y, Copper == 2 || Copper == 3 ?
  426.                              (( StackLength * NumCols / SolutionLength ) %
  427.                               NumCols ) + 1 : 3, EAST );
  428.                 return AllocStack( x - 1, y, DefRemDir( EAST ));
  429.             }
  430.         }
  431.         break;
  432.     case SOUTH:
  433.         if( y > 0 )
  434.         {
  435.             if( !TopWallActive( x, y ))
  436.             {
  437.                 Push( Bob, Cell );
  438.                 DrawSolution( Bob, x, y - 1, Copper == 2 || Copper == 3 ?
  439.                              (( StackLength * NumCols / SolutionLength ) %
  440.                               NumCols ) + 1 : 3, NORTH );
  441.                 return AllocStack( x, y - 1, DefRemDir( NORTH ));
  442.             }
  443.         }
  444.         break;
  445.     default:
  446.         break;
  447.     }
  448.     
  449.     return 0L;
  450. }
  451.  
  452. LONG SolveMaze( Maze *Bob, LONG x, LONG y, LONG sx, LONG sy )
  453. {
  454.     Stack *Cell, *NewCell;
  455.     LONG RetVal;
  456.     
  457.     Cell = AllocStack( x, y, ( BYTE * )&( DirArray[RangeRand( 24 )] ));
  458.     
  459.     do
  460.     {
  461.         RetVal = ContinueBlanking();
  462.  
  463.         if( Cell->st_x == sx && Cell->st_y == sy )
  464.             break;
  465.  
  466.         if( NewCell = SolveDirection( Bob, Cell, 0 ))
  467.         {
  468.             Cell = NewCell;
  469.             continue;
  470.         }
  471.         
  472.         if( NewCell = SolveDirection( Bob, Cell, 1 ))
  473.         {
  474.             Cell = NewCell;
  475.             continue;
  476.         }
  477.         
  478.         if( NewCell = SolveDirection( Bob, Cell, 2 ))
  479.         {
  480.             Cell = NewCell;
  481.             continue;
  482.         }
  483.         
  484.         if( NewCell = SolveDirection( Bob, Cell, 3 ))
  485.         {
  486.             Cell = NewCell;
  487.             continue;
  488.         }
  489.         
  490.         x = Cell->st_x;
  491.         y = Cell->st_y;
  492.  
  493.         FreeVec( Cell );
  494.         Cell = Pop( Bob );
  495.  
  496.         if( Cell->st_x > x )
  497.             DrawSolution( Bob, x, y, 0, EAST );
  498.         if( Cell->st_x < x )
  499.             DrawSolution( Bob, x, y, 0, WEST );
  500.         if( Cell->st_y > y )
  501.             DrawSolution( Bob, x, y, 0, NORTH );
  502.         if( Cell->st_y < y )
  503.             DrawSolution( Bob, x, y, 0, SOUTH );
  504.     }
  505.     while( Cell &&( RetVal == OK ));
  506.     
  507.     if( Cell )
  508.     {
  509.         do
  510.             FreeVec( Cell );
  511.         while( Cell = Pop( Bob ));
  512.     }
  513.     
  514.     return RetVal;
  515. }
  516.  
  517. LONG Blank( PrefObject *Prefs )
  518. {
  519.     LONG ToFrontCount = 0, i, RetVal, StartY, SolutionY;
  520.     struct RastPort *Rast;
  521.     struct Screen *Scr;
  522.     struct Window *Wnd;
  523.     Maze *Bob;
  524.     
  525.     Scr = OpenScreenTags( 0L, SA_Depth, Prefs[MODE].po_Depth, SA_Behind, TRUE,
  526.                          SA_Overscan, OSCAN_STANDARD, SA_Quiet, TRUE,
  527.                          SA_DisplayID, Prefs[MODE].po_ModeID, TAG_DONE );
  528.     
  529.     if( Scr )
  530.         Bob = AllocMaze( Scr, ( Scr->Width - 1 ) / Prefs[CELLSIZE].po_Level,
  531.                         ( Scr->Height - 1 ) / Prefs[CELLSIZE].po_Level,
  532.                         MEMF_CLEAR );
  533.     
  534.     if( Scr && Bob )
  535.     {
  536.         SetRGB4( &Scr->ViewPort, 0, 0L, 0L, 0L );
  537.         
  538.         if( !Prefs[SOLVEDEL].po_Level )
  539.         {
  540.             SolDelay = 0;
  541.             SolPeriod = 100;
  542.         }
  543.         else if( Prefs[SOLVEDEL].po_Level < 12 )
  544.         {
  545.             SolDelay = 1;
  546.             SolPeriod = 12 - Prefs[SOLVEDEL].po_Level;
  547.         }
  548.         else
  549.         {
  550.             SolDelay = Prefs[SOLVEDEL].po_Level - 10;
  551.             SolPeriod = 1;
  552.         }
  553.         
  554.         Rast = &( Scr->RastPort );
  555.         NumCols = ( 1L << Rast->BitMap->Depth ) - 1;
  556.         
  557.         SetRGB4( &Scr->ViewPort, 2, 0x0FL, 0x02L, 0x02L );
  558.  
  559.         switch( Copper = Prefs[COPPER].po_Active )
  560.         {
  561.         case 0:
  562.             SetRGB4( &Scr->ViewPort, 3, 0x0DL, 0x0DL, 0x0DL );
  563.             setCopperList(( LONG )Scr->Height, 1, &Scr->ViewPort, &custom );
  564.             break;
  565.         case 1:
  566.             SetRGB4( &Scr->ViewPort, 3, 0x02L, 0x02L, 0x0DL );
  567.             setCopperList(( LONG )Scr->Height, 3, &Scr->ViewPort, &custom );
  568.             break;
  569.         case 2:
  570.             ColorTable = RainbowPalette( Scr, 0L, 1L, 0L );
  571.             break;
  572.         case 3:
  573.             ColorTable = RainbowPalette( Scr, 0L, 1L, 0L );
  574.             setCopperList(( LONG )Scr->Height, 1, &Scr->ViewPort, &custom );
  575.             break;
  576.         default:
  577.             break;
  578.         }
  579.  
  580.         Wnd = BlankMousePointer( Scr );
  581.         ScreenToFront( Scr );
  582.         
  583.         do
  584.         {
  585.             SetRast( Rast, 0 );
  586.  
  587.             if( Copper != 2 )
  588.                 SetRGB4( &Scr->ViewPort, 1, 0x02L + RangeRand( 3 ),
  589.                         0x0DL - RangeRand( 5 ), 0x02L + RangeRand( 3 ));
  590.  
  591.             if(!( ++ToFrontCount % 60 ))
  592.                 ScreenToFront( Scr );
  593.             
  594.             if( Copper != 2 && Copper != 4 )
  595.                 SetAPen( Rast, 1 );
  596.             else
  597.                 SetAPen( Rast, RangeRand( NumCols ) + 1L );
  598.  
  599.             Move( Rast, 0, 0 );
  600.             Draw( Rast, 0, Bob->mz_Height * Bob->mz_HeiStep );
  601.             Draw( Rast, Bob->mz_Width * Bob->mz_WidStep,
  602.                  Bob->mz_Height * Bob->mz_HeiStep );
  603.             Draw( Rast, Bob->mz_Width * Bob->mz_WidStep, 0 );
  604.             Draw( Rast, 0, 0 );
  605.             
  606.             StartY = RangeRand( Bob->mz_Height );
  607.             SolutionY = RangeRand( Bob->mz_Height );
  608.             
  609.             StackLength = SolutionLength = 0;
  610.  
  611.             RetVal = ConstructMaze( Bob, 0, StartY, Bob->mz_Width - 1,
  612.                                    SolutionY );
  613.  
  614.             if( RetVal == OK )
  615.             {
  616.                 if( Copper != 2 )
  617.                 {
  618.                     DrawSolution( Bob, 0, StartY, 2, WEST );
  619.                     DrawSolution( Bob, Bob->mz_Width - 1, SolutionY, 2, EAST );
  620.                 }
  621.                 else
  622.                 {
  623.                     DrawSolution( Bob, 0, StartY, 1, WEST );
  624.                     DrawSolution( Bob, Bob->mz_Width - 1, SolutionY, 1, EAST );
  625.                 }
  626.                 
  627.                 RetVal = SolveMaze( Bob, 0, StartY, Bob->mz_Width - 1,
  628.                                    SolutionY );
  629.  
  630.                 if( RetVal == OK )
  631.                 {
  632.                     for( i = 0; i < Bob->mz_Width * Bob->mz_Height; i++ )
  633.                         Bob->mz_Cells[i] = 0;
  634.  
  635.                     for( i = 0; i < ( Bob->mz_Width+1 ) * Bob->mz_Height; i++ )
  636.                         Bob->mz_LeftWalls[i] = 0;
  637.                     
  638.                     for( i = 0; i < Bob->mz_Width * ( Bob->mz_Height+1 ); i++ )
  639.                         Bob->mz_TopWalls[i] = 0;
  640.                 }
  641.             }
  642.         }
  643.         while( RetVal == OK );
  644.         
  645.         UnblankMousePointer( Wnd );
  646.  
  647.         switch( Copper )
  648.         {
  649.         case 0:
  650.         case 1:
  651.             clearCopperList( &Scr->ViewPort );
  652.             break;
  653.         case 3:
  654.             clearCopperList( &Scr->ViewPort );
  655.         case 2:
  656.             RainbowPalette( 0L, ColorTable, 1L, 0L );
  657.             break;
  658.         default:
  659.             break;
  660.         }
  661.  
  662.     }
  663.     else
  664.         RetVal = FAILED;
  665.     
  666.     if( Bob )
  667.         FreeMaze( Bob );
  668.     
  669.     if( Scr )
  670.         CloseScreen( Scr );
  671.     
  672.     return RetVal;
  673. }
  674.